function pickHero(id, obj) {
    $('#pickedHero').attr('hid', id);
    $('.bhero').removeClass('selected');
    $(obj).addClass('selected');
}
function pickTeam(id, obj) {
    $('#pickedTeam').attr('hid', id);
    $('.bteam').removeClass('selected');
    $(obj).addClass('selected');
}
function connectToRoom(roomId) {

    var heroId = $('#pickedHero').attr('hid');
    var teamId = $('#pickedTeam').attr('hid');
    ws.sendMessage('gm{"roomId":"' + roomId + '","heroId":"' + heroId + '","teamId":"' + teamId + '"}');
}
function initHeroMenuList() {
    var selected = "";
    $("#heroesList").html('');
    for (var n = 0; n < basicHeroList.length; n++) {
        if (basicHeroList[n].typeId == 1)
            $("#heroesList").append('<div onclick="pickHero(' + basicHeroList[n].id + ', this);" class="bhero"><div class="img" style="background-image: url(img/heroes_pic/' + basicHeroList[n].dir + '_full.png)"></div><div class="name">' + basicHeroList[n].name + '</div></div>');
    }
    $("#heroesList").append('<div class="cl"></div>');
    for (var n = 0; n < basicHeroList.length; n++) {
        if (basicHeroList[n].typeId == 2)
            $("#heroesList").append('<div onclick="pickHero(' + basicHeroList[n].id + ', this);" class="bhero"><div class="img" style="background-image: url(img/heroes_pic/' + basicHeroList[n].dir + '_full.png)"></div><div class="name">' + basicHeroList[n].name + '</div></div>');
    }
    $("#heroesList").append('<div class="cl"></div>');
    for (var n = 0; n < basicHeroList.length; n++) {
        if (basicHeroList[n].typeId == 3)
            $("#heroesList").append('<div onclick="pickHero(' + basicHeroList[n].id + ', this);" class="bhero"><div class="img" style="background-image: url(img/heroes_pic/' + basicHeroList[n].dir + '_full.png)"></div><div class="name" >' + basicHeroList[n].name + '</div></div>');
    }
    $("#heroesList").append('<div class="cl"></div>');
    $("#heroesList .bhero").first().addClass("selected");
}
function resetHeroPanel() {
    $("#panelHeroes").html("");
    var nn = 0;
    for (var k = 0; k < objects.unitsStaticInfo.length; k++) {
        if (objects.unitsStaticInfo[k].teamId == 1 && objects.unitsStaticInfo[k].typeId < 4) {
            var tmpBasicHero = getBasicHero(objects.unitsStaticInfo[k].heroId);
            $("#panelHeroes").append("<div class='winHero' onclick='goToHero(" + objects.unitsStaticInfo[k].gameId + ");' style='background-image: url(img/heroes_pic/" + tmpBasicHero.dir + "_full.png);'></div>");
            nn++;
        }
    }
    for (var k = 0; k < 5 - nn; k++) {
        $("#panelHeroes").append('<div class="winHero"></div>');
    }
    nn = 0;
    $("#panelHeroes").append(' <div class="winTimer">time</div>');
    for (var k = 0; k < objects.unitsStaticInfo.length; k++) {
        if (objects.unitsStaticInfo[k].teamId == 2 && objects.unitsStaticInfo[k].typeId < 4) {
            var tmpBasicHero = getBasicHero(objects.unitsStaticInfo[k].heroId);
            $("#panelHeroes").append("<div class='winHero' onclick='goToHero(" + objects.unitsStaticInfo[k].gameId + ");' style='background-image: url(img/heroes_pic/" + tmpBasicHero.dir + "_full.png);'></div>");
            nn++;
        }
    }
    for (var k = 0; k < 5 - nn; k++) {
        $("#panelHeroes").append('<div class="winHero"></div>');
    }
}